package com.personal.system.service.impl.content.web;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.personal.common.result.Result;
import com.personal.system.entity.content.WebConfig;
import com.personal.system.mapper.content.WebConfigMapper;
import com.personal.system.service.content.web.WebConfigService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class WebConfigServiceImpl extends ServiceImpl<WebConfigMapper, WebConfig> implements WebConfigService {

    /**
     * 网站配置
     * @return
     */
    @Override
    public Result listWebConfig() {
        WebConfig webConfig = baseMapper.selectOne(new QueryWrapper<WebConfig>().last("limit 1"));
        return Result.ok(webConfig);
    }

    /**
     * 修改网站配置
     * @param webConfig
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result updateWebConfig(WebConfig webConfig) {
        baseMapper.updateById(webConfig);
        return Result.ok();
    }
}